package com.itany.hotel.util;

import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

public class ActionFormUtil {

    public static <O> O parserRequest(HttpServletRequest request,Class<O> cls)throws ServletException {

        try {
            O obj=cls.newInstance();

            BeanUtils.populate(obj,request.getParameterMap());

            return obj;
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServletException(e);
        }


    }
}
